Exit
Exit
 
Parameters: NONE
Returns: NONE
 

      Exit terminates the current loop and continues program execution after that loops closing statement.



FACTS:


      * Also See: ExitFor, ExitWhile, ExitRepeat, or ExitDo, to explicitly define the loop you want to exit.

      * Exit can only exit the current loop. So if you've inside a couple of nested loops (of the same type) you might find Goto an easy option to exit out of them.




Mini Tutorial #1:



  
; Start of a DO/LOOP loop
  Do
     
     Print "Here we go..."
     
   ; Exit this DO/LOOP and continue running the code
   ; beyond the LOOP statement.  Thus skipping following
   ; print statement
     Exit
     
     Print "... but we don't go here."
  Loop
  
  Print "Loop Exited"
  
; Display the Screen and wait for the user to press a key
  Sync
  WaitKey
  




This example would output.

  
  Here we go...
  Loop Exited
  
  







Mini Tutorial #2:



  
; start of programs main DO/LOOP
  Do
     
   ; clear the screen
     Cls 0
     
   ; Start of For NExt Loop
     For X=0 To 1000
      ; Check if the loop counter variable X
      ; is greater than 100, if so, EXIT
      ; the FOR/NEXT loop
        If X> 10
           Print "Exiting For/Next"
           Exit
        EndIf
        Print "X="+Str$(X)
     Next
     
   ; show the screen to the user
     Sync
     
   ; loop back to the do statement to keep program running
  Loop
  




This example would output.

  
  X=0
  X=1
  X=2
  X=3
  X=4
  X=5
  X=6
  X=7
  X=8
  X=9
  X=10
  Exiting For/Next
  
  



 
Related Info: Continue | ExitDo | ExitFor | ExitFunction | ExitRepeat | ExitWhile | Loops :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com